Configuring the engine before launch

When initializing the component, by default, it will :

However, if this needs to be altered, it is possible to do some configuration work to better fit your needs. This tutorial will cover this aspect.

Through API

To drive the configuration through the API, some includes are required :

#include <NilkinsGraphics/Configs/ConfigHolder.h> #include <NilkinsGraphics/Configs/ConfigManager.h> // Included because we will want to alter the window's size #include <NilkinsGraphics/Configs/WindowDescriptor.h>

These includes will give the possibility to retrieve the configuration structure, and manipulate it. This has to happen before initializing the component :

nkGraphics::ConfigHolder* config = nkGraphics::ConfigManager::getInstance()->getCurrentConfig() ;

Once the configuration is retrieved, you can change everything you need. For instance, if we want to create a 1280x1024 window, and rather use DirectX 11, we can do :

config->_wantedApi = nkGraphics::RENDERING_API::D3D11 ; config->_window.setValue(nkGraphics::WINDOW_PROPS::WIDTH, 1280) ; config->_window.setValue(nkGraphics::WINDOW_PROPS::HEIGHT, 1024) ;
New log
We now start up the application using DirectX 11 !

Another important aspect of the configuration, covered here, is to set the ResourceManager's working path.
All components, when taking a path as a parameter, will take it relative to the working path. By default, the working path is set to be the execution path, from where the program has been launched.

However, it can be interesting to alter the working directory for the components to fetch their data in a subfolder, for instance. First include :

#include <NilkinsResources/ResourceManager.h>

And change the working path to be in a Data subfolder :

nkResources::ResourceManager::getInstance()->setWorkingPath("Data") ;

Now, when passing any path to the component, for instance to load a texture, it will always be implicitly relative to the working path. For instance, Textures/tex.jpg will be relative to Data.
This will make the component fetch the texture in Data/Textures/tex.jpg, relative to the execution folder.

Through configuration file

Another way of setting this configuration is by having a configuration file.
Such behaviour can be triggered by calling :

nkGraphics::MainSystem::getInstance()->autoConfigure() ;

The file needs to be next the the executable, and called GraphicConfig.cfg. Here is an example file, showing all possible options :

// Window width 800 height 600 fullscreen 0 // Rendering vSync 0 api d3d12 // Data dataFolder ./Data/

The layout is a simple "keyword value" pair, one per line. Comments can be added by starting a line with "//".
Each entry corresponds to a call in the API. With this, it is possible for instance to do quick testing of different resolutions, or switch from a graphics API to another without recompiling the program.

And this concludes the configuration part ! You now have more tools to customize how the component boots.
In the next tutorials, we will finally learn how to get something on screen. Time for some serious business !